import axios, {AxiosResponse} from "axios";


const client = axios.create({
  headers: {
    "Accept": "application/json",
    "Content-Type": "application/json",
  },
  baseURL: "http://localhost:8718",
  timeout: undefined,
})

const onSuccess = (resp: AxiosResponse<any, any>) => {
  return resp.data;
}

const onError = (err: any) => {
  console.error(err);
}


client.interceptors.response.use(onSuccess, onError);

export const doPost = async (uri: string, data: any) => {
  return await client.post(uri, data)
}

export const doGet = async (uri: string) => {
  return await client.get(uri)
}

export const doPut = async (uri: string, data: any) => {
  return await client.put(uri, data)
}

export const doDelete = async (uri: string) => {
  return await (client.delete(uri))
}

